home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / dos / addbuffers.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  2.5 KB  |  100 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: addbuffers.c,v 1.1 1996/09/11 12:54:44 digulla Exp $
  4.     $Log: addbuffers.c,v $
  5.     Revision 1.1  1996/09/11 12:54:44  digulla
  6.     A couple of new DOS functions from M. Fleischer
  7.  
  8.     Desc:
  9.     Lang: english
  10. */
  11. #include <clib/exec_protos.h>
  12. #include <dos/dosextens.h>
  13. #include <dos/filesystem.h>
  14. #include "dos_intern.h"
  15.  
  16. /*****************************************************************************
  17.  
  18.     NAME */
  19.     #include <clib/dos_protos.h>
  20.  
  21.     __AROS_LH2(BOOL, AddBuffers,
  22.  
  23. /*  SYNOPSIS */
  24.     __AROS_LHA(STRPTR, devicename, D1),
  25.     __AROS_LHA(LONG,   numbuffers, D2),
  26.  
  27. /*  LOCATION */
  28.     struct DosLibrary *, DOSBase, 122, Dos)
  29.  
  30. /*  FUNCTION
  31.     Add or remove cache memory from a filesystem.
  32.  
  33.     INPUTS
  34.     devicename - NUL terminated dos device name.
  35.     numbuffers - Number of buffers to add. May be negative.
  36.  
  37.     RESULT
  38.     !=0 on success (IoErr() gives the actual number of buffers),
  39.     0 else (IoErr() gives the error code).
  40.  
  41.     NOTES
  42.  
  43.     EXAMPLE
  44.  
  45.     BUGS
  46.  
  47.     SEE ALSO
  48.  
  49.     INTERNALS
  50.  
  51.     HISTORY
  52.     29-10-95    digulla automatically created from
  53.                 dos_lib.fd and clib/dos_protos.h
  54.  
  55. *****************************************************************************/
  56. {
  57.     __AROS_FUNC_INIT
  58.     __AROS_BASE_EXT_DECL(struct DosLibrary *,DOSBase)
  59.     
  60.     /* Get pointer to process structure */
  61.     struct Process *me=(struct Process *)FindTask(NULL);
  62.     struct DosList *dl;
  63.     BOOL success=0;
  64.  
  65.     dl=LockDosList(LDF_DEVICES|LDF_READ);
  66.     dl=FindDosEntry(dl,devicename,LDF_DEVICES);
  67.     if(dl!=NULL)
  68.     {
  69.  
  70.         /* Get pointer to I/O request. Use stackspace for now. */
  71.         struct IOFileSys io,*iofs=&io;
  72.  
  73.         /* Prepare I/O request. */
  74.         iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  75.         iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  76.         iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  77.         iofs->IOFS.io_Device =dl->dol_Device;
  78.         iofs->IOFS.io_Unit   =dl->dol_Unit;
  79.         iofs->IOFS.io_Command=FSA_MORE_CACHE;
  80.         iofs->IOFS.io_Flags  =0;
  81.         iofs->io_Args[0]=numbuffers;
  82.  
  83.         /* Send the request. */
  84.         DoIO(&iofs->IOFS);
  85.         
  86.         /* Set error code */
  87.         if(!iofs->io_DosError)
  88.         {
  89.             me->pr_Result2=iofs->io_Args[0];
  90.             success=1; 
  91.     }else
  92.         me->pr_Result2=iofs->io_DosError;
  93.     }else
  94.         me->pr_Result2=ERROR_DEVICE_NOT_MOUNTED;
  95.     /* All Done. */
  96.     UnLockDosList(LDF_DEVICES|LDF_READ);
  97.     return success;
  98.     __AROS_FUNC_EXIT
  99. } /* AddBuffers */
  100.